home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1987 December
/
1987-12.d64
/
root race
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
188 lines
10 rem copyright 1987 compute! publications, inc. - all rights reserved
20 ifpeek(49155)<>14thengosub1600
30 dima(17,16),sc(17),v(17,16):x=rnd(-ti)
40 sys49152:fort=0to7:poke14336+160*8+t,255:next
50 print"[147]":fort=54272to54296:poket,0:next:poke54296,15
60 poke53272,31:poke53281,0:poke53280,11:h=1024:cl=54272+h:poke54278,240
70 poke53280,0:poke2040,13:poke54276,17:fc=252:fd=253
80 fort=0to127:poke832+t,0:next:fort=0to7:readx:poke832+t*3,x:next:poke53287,1
90 fort=0to9:readef(t):next:c(2)=15
100 input"[158]1 or 2 joysticks";jn:ifjn=1thenprint"[159]plug it in port one."
110 ifjn=0orjn>2then100
120 a$="[144][159][156][158][129][149][150][151][152][153][154][155]"
130 printc$" "
140 t=c(2):print"[154]select ground color with the space bar, and then hit f7."
150 ifpeek(203)=60thent=t+1:c(2)=t
160 c$=mid$(a$,(15andt)+1,1):forx=1to30:next:ifpeek(203)<>3then130
170 fort=1to15:pokeh+364+t*2,160:pokecl+364+t*2,t:next:poke198,0
180 input"[153]player one's root color (1-15)";c(0):c(0)=c(0)and15:ifc(0)=0then180
190 input"player two's root color (1-15)";c(1):c(1)=c(1)and15:ifc(1)=0then190
200 ifc(0)=c(1)thenprint"those colors are the same !!":goto180
210 poke198,0:input"[158]how many trees per player (3-9)";tn:iftn>9ortn<3then210
220 q=tn*2:print"select a game: f1=two players"
230 print" f3=game demonstration"
240 print" f5=player vs computer"
250 geta$:ifa$=""then250
260 ifa$<>"[133]"anda$<>"[134]"anda$<>"[135]"then250
270 p$(0)="computer one":p$(1)="computer two":ifa$="[134]"then330
280 ifa$="[135]"thenp$(0)="player 1":p$(1)="computer":input"[159]name";p$(0):goto330
290 input"[159]player one's name";p$(0):input"[155]player two's name";p$(1)
300 ifp$(0)="computer one"thenp$(0)="player one"
310 ifp$(1)="computer two"thenp$(1)="player two"
320 p$(0)=left$(p$(0),14):p$(1)=left$(p$(1),14)
330 fort=0toq-1:a(t,0)=t+2:next
340 gosub1420:poke53269,1:qz=0
350 u=56320:u2=56321:f=0
360 m=0:print"[146]"
370 pl=0:cm=a$="[134]":gosub1090:ifm=q-1-rcthenrc=rc+1:m=0:l=0
380 ifrc=q-2then420
390 pl=1:cm=(a$="[135]"ora$="[134]"):gosub1090:ifm=q-1-rcthenrc=rc+1:m=0:l=0
400 ifrc=q-2then420
410 goto370
420 s1=sc(a(0,q-2)-2):s2=sc(a(1,q-2)-2):b=(a(0,q-2)and1):pokefc,0
430 ifs1>s2andb=0thenk=0
440 ifs1>s2andb=1thenk=1
450 ifs2>s1andb=0thenk=1
460 ifs2>s1andb=1thenk=0
470 g$=p$(kand1)
480 poke53269,0:poke198,0:pokefd,0:g2$="s":ifabs(s1-s2)=1theng2$=""
490 fort=0to300:next
500 ifs1<>s2thenprint""sp$"the winner is [158]"g$", whose root"
510 ifs1=s2thenprint"[159]a tie game. (good defense by player 2)"
520 ifs1<>s2thenprint"system is"abs(s1-s2)"yard"g2$" larger."
530 readb,d,x:ifb<0then550
540 poke54272,d:pokefc,b:fort=1tox*88:next:goto530
550 poke54272,0:pokefc,0:restore:fort=1to18:readx:next
560 print"[153] play same game again? (y<< >>n)";
570 ifpeek(203)=39orpeek(u2)=247thenprint"[147]":j=1:goto600
580 ifpeek(203)=25orpeek(u2)=251thenj=2:goto600
590 goto570
600 print"[147]":fort=0to17:forx=0to16:sc(t)=0:a(t,x)=0:next:next:rc=0:lg=0
610 onjgoto120,330
620 e=0:print" ";
630 ifrx+d>q-rc-2then780
640 ifrx+d<0then780
650 ifa(rx+d,rc+1)and1<>0then780
660 b=int(rnd(-ti)*5):pokefd,0:pokefc,ef(b*2):pokefd,ef(b*2+1)
670 a(rx+d,rc+1)=a(rx,rc):sc(a(rx,rc)-2)=sc(a(rx,rc)-2)+1:v(rx+d,rc+1)=d+2
680 t=int(rnd(0)*3)*4
690 ifdthen730
700 ifpeek(x+h)<>143thenpokex+h,140+t/4:goto720
710 pokeh+x,130+t
720 pokex+h+1,131+t:pokex+cl,c(pl):pokex+cl+1,c(pl)
730 ifnotdthen770
740 pokex+h-1,128+t:pokex+cl-1,c(pl):pokex+cl,c(pl)
750 ifpeek(x+h)<>143thenpokex+h,140+t/4:goto770
760 pokeh+x,129+t
770 m=m+1:return
780 e=-1:return
790 pokefd,0:pokefc,2:poke54276,33
800 print"[153]no moves are possible for "p$(pl);:fort=1to2000:next
810 pokefc,0:poke54276,17:return
820 ifxt>0thenifa(xt-1,ry)and1=0anda(xt+1,ry)and1=0thendd=notdd
830 ifxt=0thenxt=1:dd=0
840 return
850 ff=0:d=1:ifrx<0thenrx=0
860 ifrc=0andf=<tn-2thenf=f+1:rx=tn-1:goto1120
870 iff>1andrc>0thenrx=int(tn-ry/2)-1:ifrx<0thenrx=0
880 ff=-1:ifry>1then920
890 dd=-1:ifrx>0thenif(-a(rx-1,ry)and1)thenif-a(rx+1,ry)and1thenrx=rx-1:goto890
900 ifrx>0thenif(-a(rx-1,ry)and1)and(a(rx+1,ry)and1=0)thendd=0
910 goto1120
920 fort=0totn*2:if(a(t,1)and1)=0thennext
930 ift=tnthenif-(tnand1)thencs=-1:tr=tn+2:goto980
940 ift=tn-1thenif(tnand1)=0thencs=-1:tr=tn+3:qz=-1:goto970
950 lg=0:fort=3totn*2-5step2:ifsc(t)>lgthenlg=sc(t):tr=t+2
960 next:cs=0:iftr-2>tnthencs=-1
970 ifcs=0then1040
980 dd=-1:fort=1totn*2-ry-1:ifa(t,ry)<>trthennext
990 xt=t
1000 if(ry>tn-1)thenif(-a(xt+1,ry)and1)and(a(0,ry)and1=1)thenxt=xt+1
1010 dd=0:goto1000
1020 ifqzthenrx=xt:dd=-1:goto1120
1030 goto1080
1040 d=1:dd=0:fort=tn*2-ryto1step-1:ifa(t,ry)<>trora(t,ry+1)>0thennext
1050 xt=t
1060 ifry>tn-1andxt>0thenif(-a(xt-1,ry)and1)thenxt=xt-1:dd=-1:goto1060
1070 ifpeek(203)=2thenend
1080 gosub820:rx=xt:goto1120
1090 print""sp$;""p$(pl)"'s move..";:rx=0:ry=rc:d=1
1100 poke53269,0:b=0:e=0:ff=0:ifcmthenrx=int(rnd(1)*(q-ry-2))
1110 ifa$="[135]"andpl=1then850
1120 if(rx>q-rc-1)andbthenrx=0
1130 if(rx<0)andbthenrx=q-rc-1
1140 ifrx>q-rc-1andnotbthene=e+1:rx=0
1150 ifrx<0andnotbthene=e+1:rx=q-rc-1
1160 py=99+rc*8:px=(ce+rc)*8+24+rx*16:ife>1then790
1170 if(a(rx,rc)and1)<>plthenrx=rx+d:goto1120
1180 x=int((px-24)/8)+int((py-50)/8)*40
1190 ifpeek(x+h+1)<>148andpeek(x+h-1)<>148thenrx=rx+d:goto1120
1200 ifpx>255thenpoke53264,1
1210 ifpx<256thenpoke53264,0
1220 poke53248,pxand255:poke53249,py:b=-1:poke53269,1
1230 ifnotcmthen1270
1240 d=int(rnd(1)*2)-1:ifffthend=dd
1250 gosub620:ifethend=int(rnd(1)*2)-1:goto1250
1260 return
1270 j=1:ifpl=1andjn=2thenpoke56322,0:j=0
1280 if(peek(u+j)and8)=0thenrx=rx+1:d=1:goto1100
1290 if(peek(u+j)and4)=0thenrx=rx-1:d=-1:goto1100
1300 pokeu,127
1310 if(peek(u+j)and16)>0then1270
1320 print"[146]which way??? ";
1330 d=-2
1340 if(peek(u+j)and8)=0thend=0
1350 if(peek(u+j)and4)=0thend=-1
1360 poke56322,255
1370 ifd=-2then1340
1380 gosub620:ifnotethenreturn
1390 print" [158]i m p o s s i b l e m o v e"
1400 pokefd,0:poke54276,33:fork=0to5*(NULL)step.2:pokefc,abs(sin(k)*9)+3:next
1410 poke54276,17:pokefc,0:goto1090
1420 sp$=" ":ce=20-q:g$="":g2$=""
1430 print"[147]"sp$c$""
1440 fort=2toce:g$=g$+" ":next:g$=g$+"u"
1450 fort=1toce:g2$=g2$+" ":next:g2$="v"+g2$
1460 d$="ot":fort=1toq-2:d$=d$+"ot":next:d$=d$+"o"
1470 g$=""+g$
1480 x=160+h+ce:x2=160+cl+ce:fort=0totn-1:pokex+t*4,147:pokex2+t*4,c(0)
1490 pokex+t*4+40,146:pokex2+t*4+40,c(0):pokex+t*4+2,145:pokex2+t*4+2,c(1)
1500 pokex+t*4+42,144:pokex2+t*4+42,c(1)
1510 next
1520 fort=1toq-2
1530 printg$"[152]"d$c$g2$;:d$=left$(d$,len(d$)-2):g2$=g2$+" "
1540 g$=" "+g$
1550 next
1560 iftn<10thenfort=1to(10-tn)*2:printsp$;:next
1570 t=(10-tn)*2
1580 fork=0to2:poke56276-k-t*40,14:next
1590 print"";:return
1600 poke53281,1:poke53280,1:print"[147][129] copyright 1987 compute! pub., inc."
1610 printtab(10)"all rights reserved"
1620 printtab(11)"r o o t r a c e"
1630 fori=1to350:reada:x=x+a:next
1640 ifx<>25073thenprint"error in data statements.":stop
1650 restore:fort=1to66:readx:next
1660 fort=0to99:readx:poke49152+t,x:next:fort=0to183:readx:poke15360+t,x:next
1670 restore:return
1680 data 24,60,126,255,219,24,24,24,18,70,16,16,21,113,18,50,5,131
1690 data 16,195,1.5,14,239,1,16,195,1.5,18,209,1,16,195,1.5
1700 data 18,209,1,21,31,1.5,18,209,1,42,62,1.5,31,165,1,42,62,1.5
1710 data 31,165,1,18,209,1.5,31,165,1,50,60,2.5,-1,-1,-1
1720 data 169,0,141,14,220,169,251,37,1,133,1,162,0,189,0,208,157,0,56
1730 data 189,0,209,157,0,57,232,208,241,165,1,9,4,133,1,169,1,141,14
1740 data 220,169,27,141,17,208,169,127,141,13,220,169,65,141,20,3,169,192,141
1750 data 21,3,169,129,141,26,208,96,165,252,240,5,24,101,253,133,252,141,1
1760 data 212,169,1,141,25,208,169,0,141,18,208,173,13,220,41,1,240,3,76
1770 data 49,234,76,188,254
1780 data 0,0,0,3,6,12,24,24,24,24,48,224,0,0,0,0,24,24,48,51,30
1790 data 0,0,0,0,0,0,224,48,24,24,24,0,0,0,1,3,6,12,24,24,24,112,192
1800 data 0,0,0,0,24,24,12,6,3,0,0,0,0
1810 data 0,0,192,240,24,24,24,0,0,0,15,24,48,48,24,24,112,192,128
1820 data 0,0,0,0,24,12,12,7,0,0,0,0,0,0,0,0,224,48,24
1830 data 24,24,24,60,231,129,0,0,0,28,54,99,